<?
//引入所有子系统信息
include_once("../../../common/script/extender_import.php");


//**获取当前板块资料，必然载入，后续很多读取板块数据库的表格，都写成动态的了。
$_plate=$plate['link'];

//**获取板块的设置，必然载入
include_once("../model/setting.php");


//根据筛选框传递过来的内容，组装查找语句
include_once("script/set_condition.php");


//根据页面信息，组装查找语句
include_once("script/set_page.php");


//根据页面数量信息，筛选信息，创造url，供页码使用
include_once("script/set_url.php");
include_once("script/set_order.php");



//获取数据。注意带上翻页，搜索，排序等数据
//$_list=select_lines_all_items($table_prefix.$_plate['table']['data'],$sort,$_condition,"$_data_start,$_quantity_per_page");


//获取单条数据，这个应该可以卸载model中
//$_data=select_one_line_all_items($table_prefix.$_plate['table']['data'],"nid > 0");





$table_Suffix="link";
$table=$table_Prefix.$table_Suffix;
?>

<?php

$query = mysql_query("SELECT COUNT(nid) FROM $table where status != '已删除' or status is null ");
$sum = mysql_result($query, 0);



$nowpageid = 1;
$detailnum = 10; //每页显示多少个产品


if ($_REQUEST ['nowpageid']) {
    $nowpageid = $_REQUEST ['nowpageid'];
} else {
    $nowpageid = 1;
}


//计算一下结果，从那条数据开始显示
$detailstar = ($nowpageid - 1) * $detailnum;


if ($sum) {

    if ($sum < $detailnum) {
        $page_count = 1;
        $detailnum = $sum;
    } //如果总数据量小于$Pagenum,（pagenum作为每页显示数据的条数，）那么只有一页,而pagenum也更改为sum 


    else if ($sum % $detailnum) {
        $page_count = (int)($sum / $detailnum) + 1;
    }
    //取总数据量除以每页数的余数 
    //如果有余数，则页数等于总数据量除以每页数的结果取整再加一


    else {
        $page_count = $sum / $detailnum;
    }
    //如果没有余数，则页数等于总数据量除以每页数的结果 

} else {
    $page_count = 0;
    $detailnum = 0;
}


$lastpage = $page_count;
$prepage = $nowpageid - 1;
$nextpage = $nowpageid + 1;


if ($nowpageid == 1) {
    $prepage = 1;
}


if ($nowpageid == $page_count) {

    if ($sum <= $detailnum) //总数数据少于每页显示数目，就把循环改成总数数目
    {
        $detailnum = $sum;
        $nextpage = $nowpageid;
    } else {
        $nextpage = $nowpageid;
        $detailnum = fmod($sum, $detailnum);
        if ($detailnum == 0) //这个if是因为当数据正好30条，能除尽的话，最后一页就会因为fmod能整除的缘故，最后一页不显示数据
        {
            $detailnum = 10;
        }
    }
    //如果现在页数等于总页数（总页数上面求出，最后一页不够循环数的时候），那么最后一页的detailnum就会等于余下数据(不足一页)的数目.

}

?>



<?

$result = mysql_query("select * from $table  where  status != '已删除' or status is null ORDER BY nid desc limit $detailstar , $detailnum");

while($row = mysql_fetch_array($result))
{
    $detail_nid[]     = $row['nid'];
    $detail_name[]    = $row['webname'];
    $detail_link[]    = $row['weblink'];
    $detail_webimg[]    = $row['webimg'];
    $detail_icon[]    = $row['icon'];
    $detail_publish[] = $row['publish'];
    $detail_status[]  = $row['status'];
}
mysql_close($con);
?>







